[mirrors]
https://www.kernel.org/pub/linux/utils/util-linux/v2.28/util-linux-2.28.tar.xz

[vars]
filesize=4119560
sha512=a1f911bdfda5985de87105d39501e501a5f9ec0fe6a433e3f2fed9a80e104342bb4a7e0e6dc9b7d677d5429249f05b343cb5370b0ea0e068dc889699d4ec1f8a
desc="System utilities for Linux, cut-down for Quirky Linux"

[deps]
curses
zlib

[build]
#this installs a cutdown set of utilities, in some cases replacing busybox applets.
#this is done from years of experience with puppy linux, where the busybox applets
#were found to be inadequate.
#this also installs libblkid and libuuid. those in e2fsprogs are disabled.
#20160516: --disable-all-programs, followed by --enable-<name> is supposed to work, but doesn't,
# so have to compile everything, then install, then delete what i don't want.
# (peculiarity of util-linux, some binary executables are not created until "make install" is executed)
#20160518 want to compile f2fs-tools statically, need libuuid.a

#20160526 mystery, doing "butch rebuild", installing to /, compiled before, this time:
# sys-utils/eject.c:41:23: fatal error: scsi/scsi.h: No such file or directory
# yes, it is missing, which is very strange. anyway, do --disable-eject
#hmmm, eudev also needs scsi/sci.h. something has wiped it out, when do a rebuild.
#ok, scsi.h, scsi_ioctl.h, sg.h are installed by musl. they were there earlier.
#...i think qky-kernel is the culprit, have modified its recipe.

patch -p1 < "$K"/util-linux-fix-nls-disabled.patch

#20160516 'more', 'pg' do not compile...
CFLAGS="-D_GNU_SOURCE $optcflags" \
LDFLAGS="$optldflags -lcurses -lterminfo" \
./configure -C \
  --prefix="$butch_prefix" --with-ncurses --enable-shared --enable-static  \
  --disable-silent-rules --disable-nls --disable-colors-default --without-udev \
  --disable-use-tty-group --without-python --without-readline \
  --enable-libmount --enable-libuuid --enable-libblkid --enable-libsmartcols \
  --enable-libfdisk --disable-more --disable-pg --disable-eject

make -j$MAKE_THREADS

if $butch_do_custom_destdir ;then
 make DESTDIR="$butch_install_dir" install
 #20160516 now keep want i want...
 WHATIWANT=' addpart cfdisk col delpart eject fdformat fdisk flock fsck getopt hwclock ldattach losetup mkfs mkswap mount partx readprofile rename resizepart rev rtcwake setarch setsid swapoff swapon umount uuidd whereis '
 dest="$butch_install_dir""$butch_prefix"
 ALLINSTALLED="$(find "$dest"/bin "$dest"/sbin -maxdepth 1 -type f | tr '\n' ' ')"
 for AINSTALLED in $ALLINSTALLED
 do
  [ ! -f $AINSTALLED ] && continue
  ANAME="$(basename $AINSTALLED)"
  [ "$(echo -n "$WHATIWANT" | grep " ${ANAME} ")" != "" ] && continue
  rm -f $AINSTALLED
 done
 #puppy-heritage thing...
 mv -f ${dest}/bin/mount ${dest}/bin/mount-FULL
 mv -f ${dest}/bin/umount ${dest}/bin/umount-FULL
 mv -f ${dest}/sbin/losetup ${dest}/sbin/losetup-FULL
else
 mkdir -p "$R"/opt/util-linux
 make DESTDIR="$R"/opt/util-linux install
 WHATIWANT=' addpart cfdisk col delpart eject fdformat fdisk flock fsck getopt hwclock ldattach losetup mkfs mkswap mount partx readprofile rename resizepart rev rtcwake setarch setsid swapoff swapon umount uuidd whereis '
 for AWANT in $WHATIWANT
 do
  AFND="$(find "$R"/opt/util-linux/bin "$R"/opt/util-linux/sbin -maxdepth 1 -type f -name "$AWANT" | head -n 1)"
  [ "$AFND" ] && cp -a -f --remove-destination $AFND "$R"/bin/
 done
 cp -a -f --remove-destination "$R"/opt/util-linux/bin/mount "$R"/bin/mount-FULL
 cp -a -f --remove-destination "$R"/opt/util-linux/bin/umount "$R"/bin/umount-FULL
 cp -a -f --remove-destination "$R"/opt/util-linux/sbin/losetup "$R"/bin/losetup-FULL
 #and all the libs etc...
 cp -a -f --remove-destination "$R"/opt/util-linux/include "$R"/
 cp -a -f --remove-destination "$R"/opt/util-linux/lib "$R"/
 cp -a -f --remove-destination "$R"/opt/util-linux/share "$R"/
 rm -rf "$R"/opt/util-linux
fi
